<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>个人中心</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f2f2f2;
            padding: 20px;
        }

        .container {
            max-width: 600px;
            margin: 0 auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
        }

        .profile {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
        }

        .profile img {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            margin-right: 20px;
        }

        .profile .info {
            font-size: 18px;
            font-weight: bold;
        }

        .profile .edit {
            color: blue;
            cursor: pointer;
            text-decoration: underline;
        }

        .edit-form {
            display: none;
            margin-top: 20px;
        }

        .edit-form input[type="file"] {
            margin-bottom: 10px;
        }

        .edit-form input[type="submit"] {
            padding: 6px 12px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            margin-bottom: 0;
            font-weight: normal;
            line-height: 1.42857143;
            white-space: nowrap;
            vertical-align: middle;
            cursor: pointer;
            border: 1px solid transparent;
            border-radius: 4px;
            color: #fff;
            background-color: #337ab7;
            border-color: #2e6da4;
        }

        .edit-form input[type="submit"]:hover {
            background-color: #286090;
            border-color: #204d74;
        }
    </style>
    <script>
        function showEditForm() {
            document.getElementById("edit-form").style.display = "block";
        }
    </script>
</head>
<body>
<div class="container">
    <p class="success" th:text="${success}"></p>
    <div class="profile">
        <img th:src="@{${user.avatar}}" alt="头像">
        <div class="info">
            <p>昵称：<span th:text="${user.name}"></span></p>
            <p>Phone：<span th:text="${user.phone}"></span></p>
            <p>性别：男</p>
            <p class="edit" onclick="showEditForm()">修改头像</p>
        </div>
    </div>
    <div id="edit-form" class="edit-form">
        <form method="post" th:action="@{/upload}" enctype="multipart/form-data">
            <input type="file" name="fileToUpload" accept="image/*">
            <input type="hidden" name="id" th:value="${user.id}">
            <input type="hidden" name="name" th:value="${user.name}"/>
            <input type="submit" value="保存">
        </form>
    </div>
</div>
<script>
    var success = document.querySelector('.success');
    if (success.innerText !=''){
        window.top.location.reload();
    }
</script>
</body>
</html>
